<!DOCTYPE HTML>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<!--[if lt IE 9]>
	<script type="text/javascript" src="lib/html5.js"></script>
	<script type="text/javascript" src="lib/respond.min.js"></script>
	<script type="text/javascript" src="lib/PIE_IE678.js"></script>
	<![endif]-->
	<link href="__PUBLIC__/css/H-ui.min.css" rel="stylesheet" type="text/css" />
	<link href="__PUBLIC__/css/H-ui.admin.css" rel="stylesheet" type="text/css" />
	<link href="__PUBLIC__/css/style.css" rel="stylesheet" type="text/css" />
	<link href="__PUBLIC__/lib/Hui-iconfont/1.0.6/iconfont.css" rel="stylesheet" type="text/css" />
	<link href="Tpl/Admin/common/form.css" rel="stylesheet" type="text/css" />
	<!--[if IE 6]>
	<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
	<script>DD_belatedPNG.fix('*');</script>
	<![endif]-->
	<title>房间列表</title>
</head>
<body>
	<div class="pd-20">
		<!-- <div class="text-c"> 日期范围：
			<input type="text" onfocus="WdatePicker()" id="datemin" class="input-text Wdate" style="width:120px;">
			-
			<input type="text" onfocus="WdatePicker()" id="datemax" class="input-text Wdate" style="width:120px;">
			<input type="text" class="input-text" style="width:250px" placeholder="输入房间名称或地址" id="" name="">
			<button type="submit" class="btn btn-success radius" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜房间</button>
		</div> -->
		<div class="text-c">
			<form action="" method="POST"  autocomplete="off" class="sugForm">
				<input type="text" class="input-text" style="width:400px" placeholder="输入关键词搜索" value="" id="searchName" name="keyword">
				<span type="submit" class="btn btn-success radius searchButton" id="searchBtn" name=""><i class="Hui-iconfont">&#xe665;</i>搜索</span>
			</form>
		</div>
		<table class="table table-border table-bordered table-bg" id="orderTable">
			<thead>
				<tr>
					<th scope="col" colspan="9">所有工单</th>
				</tr>
				<tr class="text-c">
					<th width="40">工单编号</th>
					<th width="40">工单状态</th>
					<th width="100">工单大类</th>
					<th width="100">工单细类</th>
					<th width="200">事件说明</th>
					<th width="200">电话号码</th>
					<th width="200">加急情况</th>
					<th width="200">创建时间</th>
					<th width="100">操作</th>
				</tr>
			</thead>
			<tbody class="perTableTbody">
				
			</tbody>
		</table>
		
	</div>
	<script type="text/javascript" src="__PUBLIC__/lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="__PUBLIC__/lib/layer/2.1/layer.js"></script>
	<script type="text/javascript" src="__PUBLIC__/lib/laypage/1.2/laypage.js"></script>
	<script type="text/javascript" src="__PUBLIC__/lib/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript" src="__PUBLIC__/js/H-ui.js"></script>
	<script type="text/javascript" src="__PUBLIC__/js/H-ui.admin.js"></script>
	<script type="text/javascript" src="__PUBLIC__/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
	<script type="text/javascript" src="__PUBLIC__/js/getUrl.js"></script>
<!--	<script type="text/javascript" src="Tpl/Service/common/order/see.js"></script>-->
	<script type="text/javascript">
		

//权限复选框
// $(document).on("click",".perTableTbody checkbox");

/*
参数解释：
title	标题
url		请求的url
id		需要操作的数据id
w		弹出层宽度（缺省调默认值）
h		弹出层高度（缺省调默认值）
*/
// 全局
var info={
	index:0,//下拉索引
	customerId:0,
	keyword:''//搜索关键词
}
$(function(){
	info.customerId=$.getUrlVar('customerId');
	work.init();
});

        var work={
	/*·····························初始化························*/
	init:function(){
		this.eventListen();
		this.dataTable();
	},
	/*·····························事件监听························*/
	eventListen:function(){
		// 按钮颜色切换和取值放入隐藏域
		$(document).on("click","#buttonGroup button",function(){
			$("#Bcate").attr("value",$(this).text());
			$("#buttonGroup button").removeClass("btn-primary");
			$(this).addClass("btn-primary");
			var signId="#Scate";
			var type=$(this).attr("type");
			work.getDict(signId,type);
		});
// 搜索按钮点击
		$(document).on("click","#searchBtn",function(){
			info.keyword=$("#searchName").val();
			$("#orderTable").dataTable().api().draw();
		});
//回车搜索界面
// // 回车事件
	    document.onkeydown = function(e){
	                 var ev = document.all ? window.event : e;
	                 if(ev.keyCode==13) {
	                   e.preventDefault();
	                    info.keyword=$("#searchName").val();
	                   $("#orderTable").dataTable().api().draw();
	                 }
	    }
	// 查看详情按钮
		$(document).on("click",".infoBtn",function(){
			var id=$(this).attr("uid");
			var url='/index.php?m=Service&c=Order&a=info&ID='+id;
			work.layerOpen('工单详情',url,'800px','500px');
		});
	},
	/*·····························功能性函数························*/
	// iframe页面弹窗
	layerOpen:function(title,url,w,h){
		(w==null)?w='800px':w=w;
		(h==null)?h='600px':h=h;
		layer.open({
			type: 2,
			area: [w,h],
			fix: false, //不固定
			maxmin: true,
			shade:0.4,
			title: title,
			content:url
		});
	},
	
	/*·····························插件初始化························*/
	dataTable:function(){
		  var table=$("#orderTable");
	      var t=table.dataTable({
	        "ajax":function(data,callback,setting){
	          var page = table.api().page.info();

	          $.post("/index.php?m=Service&c=Order&a=search",{pageIndex:page.page+1,pageSize:page.length,select:info.keyword,customer_id:info.customerId},function(data,status){
	            console.log(data);
	            callback(data); 
	          });
	        },
              

        
            "type":"post",
	        "pageLength":10,
	          "ordering":false,
	          "deferRender": true,
	          "columns":[
	          {"data":"ID"},
	          {"data":"TO_DEPT"},
	          {"data":"DATA_9"},
	          {"data":"DATA_10"},
	          {"data":"DATA_12"},
	          {"data":"DATA_11"},
	          {"data":"work_level"},
	          {"data":"create_time"},
	          {"data":"ID"}
	          ],
	          "columnDefs":[
	           {
	            "targets":1,
	            "data":"TO_DEPT",
                
	            "render":function(data,type,full,meta){
	            	if(data==null){
	            		var poStr='未指派';
	            	}else{
	            		var poStr='已指派';
	            	}
	              
	              return poStr;
	            }

	          },
	           {
	            "targets":6,
	            "data":"work_level",
	            "render":function(data,type,full,meta){
	              	switch(data){
	              		case '0':
	              			return '普通';
	              			break;
	              		case '2':
	              			return '<span class="c-red">紧急</span>';
	              			break;
	              	}
	            }

	          },
	          {
	            "targets":8,
	            "data":"id",
	            "render":function(data,type,full,meta){
	              var poStr='<a href="javascript:;" uid="'+data+'" class="label label-success radius infoBtn">查看详情</a>';
	              return poStr;
	            }

	          }
	          ],
	        "fnCreatedRow":function(row,data,index){
	          //row 表示当前tr，data表示当前行的元素对象，index表示当前tr索引
	        },
//              type:"post",
	      "bPaginate": true, //翻页功能
	      // "processing": true,
	      "searching":false,
	      "serverSide": true//服务器模式
	        });
		}
}

</script>
</body>
</html>